home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1997 #1 / Amiga Plus CD - 1997 - No. 01.iso / pd / programmierung / mesa-1.2.8 / widgets / src / mesaworkstation.c < prev   
C/C++ Source or Header  |  1996-05-27  |  16KB  |  737 lines

  1. /* MesaWorkstation.c -- Implementation file for the Mesa Workstation widget
  2.    Copyright (C) 1995 Thorsten.Ohl @ Physik.TH-Darmstadt.de
  3.  
  4.    This library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License as published by the Free Software Foundation; either
  7.    version 2 of the License, or (at your option) any later version.
  8.  
  9.    This library is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU Library General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU Library General Public
  15.    License along with this library; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.    $Id: MesaWorkstation.c,v 1.16 1995/06/08 09:51:12 ohl Exp $
  19.  */
  20.  
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <math.h>
  24. #include <X11/IntrinsicP.h>
  25. #include <X11/StringDefs.h>
  26. #include <GL/glu.h>
  27. #include <GL/xmesa.h>
  28. #include <GL/MesaWorkstationP.h>
  29.  
  30. #if STDC_HEADERS
  31. # include <string.h>
  32. #else
  33. # ifndef HAVE_STRCHR
  34. #  define strchr index
  35. #  define strrchr rindex
  36. # endif
  37. char *strchr (), *strrchr ();
  38. # ifndef HAVE_MEMCPY
  39. #  define memcpy(d, s, n) bcopy ((s), (d), (n))
  40. # endif
  41. # ifndef HAVE_MEMMOVE
  42. #  define memmove(d, s, n) bcopy ((s), (d), (n))
  43. # endif
  44. #endif
  45.  
  46. #ifndef M_PI
  47. #define M_PI 3.14159265358979323846
  48. #endif
  49.  
  50. #define MesaProjection(_widget) \
  51.    (((MesaWorkstationWidget)_widget)->mesaWorkstation.projection)
  52. #define MesaView(_widget) \
  53.    (((MesaWorkstationWidget)_widget)->mesaWorkstation.view)
  54. #define MesaNextObject(_widget) \
  55.    (((MesaWorkstationWidget)_widget)->mesaWorkstation.next_object)
  56. #define MesaAllocatedObjects(_widget) \
  57.    (((MesaWorkstationWidget)_widget)->mesaWorkstation.allocated_objects)
  58. #define MesaObjects(_widget) \
  59.    (((MesaWorkstationWidget)_widget)->mesaWorkstation.objects)
  60.  
  61.  
  62. /* Private utility functions. */
  63.  
  64.  
  65. /* Resources. */
  66.  
  67.  
  68. /* Actions and their translations. */
  69.  
  70. static void
  71. Projection (Widget w, XEvent *event, String *argv, Cardinal *argc)
  72. {
  73.   LOG (w);
  74.  
  75.   if (*argc == 0)
  76.     return;
  77.  
  78.   if ((MesaProjection(w).type != FRUSTUM)
  79.       && (MesaProjection(w).type != ORTHO))
  80.     return;
  81.  
  82.   switch (*argv[0])
  83.     {
  84.     case 'p':
  85.       MesaProjection(w).type = FRUSTUM;
  86.       break;
  87.     case 'o':
  88.       MesaProjection(w).type = ORTHO;
  89.       break;
  90.     case 'l':
  91.       MesaProjection(w).u.vol.left *= 1.1;
  92.       break;
  93.     case 'L':
  94.       MesaProjection(w).u.vol.left /= 1.1;
  95.       break;
  96.     case 'r':
  97.       MesaProjection(w).u.vol.right *= 1.1;
  98.       break;
  99.     case 'R':
  100.       MesaProjection(w).u.vol.right /= 1.1;
  101.       break;
  102.     case 'b':
  103.       MesaProjection(w).u.vol.bottom *= 1.1;
  104.       break;
  105.     case 'B':
  106.       MesaProjection(w).u.vol.bottom /= 1.1;
  107.       break;
  108.     case 't':
  109.       MesaProjection(w).u.vol.top *= 1.1;
  110.       break;
  111.     case 'T':
  112.       MesaProjection(w).u.vol.top /= 1.1;
  113.       break;
  114.     case 'n':
  115.       MesaProjection(w).u.vol.near *= 1.1;
  116.       break;
  117.     case 'N':
  118.       MesaProjection(w).u.vol.near /= 1.1;
  119.       break;
  120.     case 'f':
  121.       MesaProjection(w).u.vol.far *= 1.1;
  122.       break;
  123.     case 'F':
  124.       MesaProjection(w).u.vol.far /= 1.1;
  125.       break;
  126.     case 'a':
  127.       MesaProjection(w).u.vol.left *= 1.1;
  128.       MesaProjection(w).u.vol.right *= 1.1;
  129.       MesaProjection(w).u.vol.bottom *= 1.1;
  130.       MesaProjection(w).u.vol.top *= 1.1;
  131.       break;
  132.     case 'A':
  133.       MesaProjection(w).u.vol.left /= 1.1;
  134.       MesaProjection(w).u.vol.right /= 1.1;
  135.       MesaProjection(w).u.vol.bottom /= 1.1;
  136.       MesaProjection(w).u.vol.top /= 1.1;
  137.       break;
  138.     }
  139.  
  140.   GLwRedrawObjects (w);
  141. }
  142.  
  143. static void
  144. Move (Widget w, XEvent *event, String *argv, Cardinal *argc)
  145. {
  146.   double scale = 0.01;
  147.   LOG (w);
  148.  
  149.   if (*argc == 0)
  150.     return;
  151.  
  152.   if (MesaView(w).type != POLAR)
  153.     return;
  154.  
  155.   if (*argc >= 2)
  156.     scale *= atof (argv[1]);
  157.  
  158.   switch (*argv[0])
  159.     {
  160.     case '+':
  161.       MesaView(w).u.polar.r /= 1.1;
  162.       break;
  163.     case '-':
  164.       MesaView(w).u.polar.r *= 1.1;
  165.       break;
  166.     case 'l':
  167.       MesaView(w).u.polar.phi += scale * M_PI;
  168.       break;
  169.     case 'r':
  170.       MesaView(w).u.polar.phi -= scale * M_PI;
  171.       break;
  172.     case 'u':
  173.       MesaView(w).u.polar.theta -= scale * M_PI;
  174.       break;
  175.     case 'd':
  176.       MesaView(w).u.polar.theta += scale * M_PI;
  177.       break;
  178.     }
  179.  
  180.   GLwRedrawObjects (w);
  181. }
  182.  
  183. static XtActionsRec actions[] =
  184. {
  185.   /* {name, procedure} */
  186.   {"Move", Move },
  187.   {"Projection", Projection },
  188. };
  189.  
  190. static char translations[] =
  191. "~Shift<Key>Left: Move(l)\n\
  192. Shift<Key>Left: Move(l,10)\n\
  193. ~Shift<Key>Right: Move(r)\n\
  194. Shift<Key>Right: Move(r,10)\n\
  195. ~Shift<Key>Up: Move(u)\n\
  196. Shift<Key>Up: Move(u,10)\n\
  197. ~Shift<Key>Down: Move(d)\n\
  198. Shift<Key>Down: Move(d,10)\n\
  199. <Key>plus: Move(+)\n\
  200. <Key>minus: Move(-)\n\
  201. ~Shift<Key>l: Projection(l)\n\
  202. Shift<Key>l: Projection(L)\n\
  203. ~Shift<Key>r: Projection(r)\n\
  204. Shift<Key>r: Projection(R)\n\
  205. ~Shift<Key>b: Projection(b)\n\
  206. Shift<Key>b: Projection(B)\n\
  207. ~Shift<Key>t: Projection(t)\n\
  208. Shift<Key>t: Projection(T)\n\
  209. ~Shift<Key>n: Projection(n)\n\
  210. Shift<Key>n: Projection(N)\n\
  211. ~Shift<Key>f: Projection(f)\n\
  212. Shift<Key>f: Projection(F)\n\
  213. ~Shift<Key>a: Projection(a)\n\
  214. Shift<Key>a: Projection(A)\n\
  215. <Key>p: Projection(p)\n\
  216. <Key>o: Projection(o)\n";
  217.  
  218.  
  219. /* Basic widget methods.  */
  220.  
  221. #define OBJECT_CHUNK_SIZE 10
  222.  
  223. static void
  224. Initialize (Widget request, Widget new, ArgList args, Cardinal * num_args)
  225. {
  226.   LOG (new);
  227.   MesaAllocatedObjects (new) = OBJECT_CHUNK_SIZE;
  228.   MesaObjects (new) = (GLuint *)
  229.     XtCalloc (MesaAllocatedObjects (new), sizeof (GLuint));
  230.   MesaNextObject (new) = MesaObjects (new);
  231.   MesaView(new).type = NOVIEW;
  232.   MesaView(new).list = 0;
  233.   MesaProjection(new).type = NOPROJ;
  234.   MesaProjection(new).list = 0;
  235. }
  236.  
  237. #if 0
  238. static void
  239. Realize (Widget w, XtValueMask * mask,
  240.      XSetWindowAttributes * attr)
  241. {
  242.   LOG (w);
  243.   (XtSuperclass (w)->core_class.realize) (w, mask, attr);
  244. }
  245. #endif
  246.  
  247. static void
  248. Destroy (Widget w)
  249. {
  250.   LOG (w);
  251.   XtFree ((char *) MesaObjects (w));
  252. }
  253.  
  254. static void
  255. Redisplay (Widget w, XEvent *event, Region region)
  256. {
  257.   LOG (w);
  258.   if (event->xexpose.count == 0)    /* last Expose event */
  259.     GLwRedrawObjects (w);
  260. }
  261.  
  262.  
  263. /* Now use all these methods in the widget class record.  */
  264.  
  265. MesaWorkstationClassRec mesaWorkstationClassRec =
  266. {
  267.   {
  268.     /* superclass            */ (WidgetClass) &mesaDrawingAreaClassRec,
  269.     /* class_name            */ "MesaWorkstation",
  270.     /* widget_size           */ sizeof (MesaWorkstationRec),
  271.     /* class_initialize      */ NULL,
  272.     /* class_part_initialize */ NULL,
  273.     /* class_inited          */ FALSE,
  274.     /* initialize            */ Initialize,
  275.     /* initialize_hook       */ NULL,
  276.     /* realize               */ XtInheritRealize,
  277.     /* actions               */ actions,
  278.     /* num_actions           */ XtNumber (actions),
  279.     /* resources             */ NULL,
  280.     /* num_resources         */ 0,
  281.     /* xrm_class             */ NULLQUARK,
  282.     /* compress_motion       */ TRUE,
  283.     /* compress_exposure     */ TRUE,
  284.     /* compress_enterleave   */ TRUE,
  285.     /* visible_interest      */ FALSE,
  286.     /* destroy               */ Destroy,
  287.     /* resize                */ XtInheritResize,
  288.     /* expose                */ Redisplay,
  289.     /* set_values            */ NULL,
  290.     /* set_values_hook       */ NULL,
  291.     /* set_values_almost     */ XtInheritSetValuesAlmost,
  292.     /* get_values_hook       */ NULL,
  293.     /* accept_focus          */ NULL,
  294.     /* version               */ XtVersion,
  295.     /* callback_private      */ NULL,
  296.     /* tm_table              */ translations,
  297.     /* query_geometry        */ XtInheritQueryGeometry,
  298.     /* display_accelerator   */ XtInheritDisplayAccelerator,
  299.     /* extension             */ NULL
  300.   },
  301. #ifdef __GLX_MOTIF
  302.   { /* XmPrimitive fields */
  303.     /* border_highlight      */ (XtWidgetProc) _XtInherit,
  304.     /* border_unhighlight    */ (XtWidgetProc) _XtInherit,
  305.     /* translations          */ XtInheritTranslations,
  306.     /* arm_and_activate      */ NULL,
  307.     /* get_resources         */ NULL,
  308.     /* num get_resources     */ 0,
  309.     /* extension             */ NULL,
  310.   },
  311. #endif /* __GLX_MOTIF */
  312.   { /* MesaDrawingArea fields*/
  313.     /* RCS_id                */ NULL
  314.   },
  315.   { /* MesaWorkstation fields*/
  316.     /* RCS_id                */
  317.     "@(#) $Id: MesaWorkstation.c,v 1.16 1995/06/08 09:51:12 ohl Exp $"
  318.   }
  319. };
  320. WidgetClass mesaWorkstationWidgetClass
  321.   = (WidgetClass) & mesaWorkstationClassRec;
  322.  
  323.  
  324. /* More private utility functions. */
  325.  
  326. static int
  327. is_workstation (Widget w)
  328. {
  329.   if (XtClass (w) != mesaWorkstationWidgetClass)
  330.     {
  331.       XtAppError (XtWidgetToApplicationContext (w),
  332.           "Not a Mesa Workstation!");
  333.       return 0;
  334.     }
  335.   else
  336.     return 1;
  337. }
  338.  
  339. static void
  340. mesa_frustum (volume v)
  341. {
  342.   glFrustum (v.left, v.right, v.bottom, v.top, v.near, v.far);
  343. }
  344.  
  345. static void
  346. mesa_ortho (volume v)
  347. {
  348.   glOrtho (v.left, v.right, v.bottom, v.top, v.near, v.far);
  349. }
  350.  
  351. static void
  352. mesa_look_at (look_at l)
  353. {
  354.   gluLookAt (l.eyex, l.eyex, l.eyez,
  355.          l.ctrx, l.ctrx, l.ctrz,
  356.          l.upx, l.upx, l.upz);
  357. }
  358.  
  359.  
  360. static void
  361. mesa_polar (polar p)
  362. {
  363.   GLdouble r, sin_th, cos_th, sin_phi, cos_phi, u_sin_th, u_cos_th;
  364.   r = p.r;
  365.   sin_th = sin (p.theta);
  366.   cos_th = cos (p.theta);
  367.   sin_phi = sin (p.phi);
  368.   cos_phi = cos (p.phi);
  369.   u_sin_th = cos_th;
  370.   u_cos_th = -sin_th;
  371.   gluLookAt (r*sin_th*cos_phi, r*cos_th, r*sin_th*sin_phi,
  372.          0.0, 0.0, 0.0,
  373.          u_sin_th*cos_phi, u_cos_th, u_sin_th*sin_phi);
  374. }
  375.  
  376.  
  377. /* Exported utilility functions.  */
  378.  
  379. void
  380. GLwPostObject (Widget w, GLuint object)
  381. {
  382.   if (is_workstation (w))
  383.     {
  384.       if (MesaNextObject (w) > MesaObjects (w) + MesaAllocatedObjects (w))
  385.     {
  386.       MesaAllocatedObjects (w) += OBJECT_CHUNK_SIZE;
  387.       MesaObjects (w) = (GLuint *)
  388.         XtRealloc ((char *) MesaObjects (w),
  389.                sizeof (GLuint) * MesaAllocatedObjects (w));
  390.     }
  391.       *(MesaNextObject(w)++) = object;
  392.     }
  393. }
  394.  
  395. void
  396. GLwUnpostObject (Widget w, GLuint object)
  397. {
  398.   if (is_workstation (w))
  399.     {
  400.       GLuint *p;
  401.       for (p = MesaObjects (w); p < MesaNextObject (w); p++)
  402.     if (*p == object)
  403.       {
  404.         memmove (p, p + 1,
  405.              sizeof (GLuint) * (MesaNextObject (w) - p - 1));
  406.         MesaNextObject(w)--;
  407.         break;
  408.       }
  409.     }
  410. }
  411.  
  412. void
  413. GLwUnpostAllObjects (Widget w)
  414. {
  415.   if (is_workstation (w))
  416.     MesaNextObject (w) = MesaObjects (w);
  417. }
  418.  
  419. void
  420. GLwBeginView (Widget w)
  421. {
  422.   if (is_workstation (w))
  423.     {
  424.       MesaView(w).type = VIEW_LIST;
  425.       if (!glIsList (MesaView(w).list))
  426.     MesaView(w).list = glGenLists (1);
  427.       glNewList (MesaView(w).list, GL_COMPILE);
  428.     }
  429. }
  430.  
  431. void
  432. GLwEndView (void)
  433. {
  434.   glEndList ();
  435. }
  436.  
  437. void
  438. GLwPostViewList (Widget w, GLuint view)
  439. {
  440.   if (is_workstation (w))
  441.     {
  442.       MesaView(w).type = VIEW_LIST;
  443.       MesaView(w).list = view;
  444.     }
  445. }
  446.  
  447. void
  448. GLwPostViewMatrix (Widget w, GLdouble *m)
  449. {
  450.   if (is_workstation (w))
  451.     {
  452.       MesaView(w).type = VIEW_MATRIX;
  453.       memcpy (MesaView(w).u.m, m, sizeof (MesaView(w).u.m));
  454.     }
  455. }
  456.  
  457. void
  458. GLwPostCurrentView (Widget w)
  459. {
  460.   if (is_workstation (w))
  461.     {
  462.       MesaView(w).type = VIEW_MATRIX;
  463.       glGetDoublev (GL_MODELVIEW_MATRIX, MesaView(w).u.m);
  464.     }
  465. }
  466.  
  467. void
  468. GLwUnpostView (Widget w)
  469. {
  470.   if (is_workstation (w))
  471.     MesaView(w).type = NOVIEW;
  472. }
  473.  
  474. void
  475. GLwSetPolarView (Widget w, GLdouble r, GLdouble theta, GLdouble phi)
  476. {
  477.   if (is_workstation (w))
  478.     {
  479.       MesaView(w).type = POLAR;
  480.       MesaView(w).u.polar.r = r;
  481.       MesaView(w).u.polar.theta = theta;
  482.       MesaView(w).u.polar.phi = phi;
  483.     }
  484. }
  485.  
  486. GLuint
  487. GLwGetViewList (Widget w)
  488. {
  489.   if (is_workstation (w))
  490.     {
  491.       if (MesaView(w).type == VIEW_LIST)
  492.     return MesaView(w).list;
  493.     }
  494.   return 0;
  495. }
  496.  
  497. int
  498. GLwGetViewMatrix (Widget w, GLdouble *m)
  499. {
  500.   if (is_workstation (w))
  501.     {
  502.       if (MesaView(w).type == VIEW_MATRIX)
  503.     memcpy (m, MesaView(w).u.m, sizeof (MesaView(w).u.m));
  504.       return 1;
  505.     }
  506.   return 0;
  507. }
  508.  
  509. void
  510. GLwBeginProjection (Widget w)
  511. {
  512.   if (is_workstation (w))
  513.     {
  514.       MesaProjection(w).type = PROJ_LIST;
  515.       if (!glIsList (MesaProjection(w).list))
  516.     MesaProjection(w).list = glGenLists (1);
  517.       glNewList (MesaProjection(w).list, GL_COMPILE);
  518.     }
  519. }
  520.  
  521. void
  522. GLwEndProjection (void)
  523. {
  524.   glEndList ();
  525. }
  526.  
  527. void
  528. GLwPostProjectionList (Widget w, GLuint proj)
  529. {
  530.   if (is_workstation (w))
  531.     {
  532.       MesaProjection(w).type = PROJ_LIST;
  533.       MesaProjection(w).list = proj;
  534.     }
  535. }
  536.  
  537. void
  538. GLwPostProjectionMatrix (Widget w, GLdouble *m)
  539. {
  540.   if (is_workstation (w))
  541.     {
  542.       MesaProjection(w).type = PROJ_MATRIX;
  543.       memcpy (MesaProjection(w).u.m, m, sizeof (MesaProjection(w).u.m));
  544.     }
  545. }
  546.  
  547. void
  548. GLwPostCurrentProjection (Widget w)
  549. {
  550.   if (is_workstation (w))
  551.     {
  552.       MesaProjection(w).type = PROJ_MATRIX;
  553.       glGetDoublev (GL_PROJECTION_MATRIX, MesaProjection(w).u.m);
  554.     }
  555. }
  556.  
  557. void
  558. GLwUnpostProjection (Widget w)
  559. {
  560.   if (is_workstation (w))
  561.     MesaProjection(w).type = NOPROJ;
  562. }
  563.  
  564. void
  565. GLwSetFrustumProjection (Widget w,
  566.              GLdouble left, GLdouble right,
  567.              GLdouble bottom, GLdouble top,
  568.              GLdouble near, GLdouble far)
  569. {
  570.   if (is_workstation (w))
  571.     {
  572.       MesaProjection(w).type = FRUSTUM;
  573.       MesaProjection(w).u.vol.left = left;
  574.       MesaProjection(w).u.vol.right = right;
  575.       MesaProjection(w).u.vol.bottom = bottom;
  576.       MesaProjection(w).u.vol.top = top;
  577.       MesaProjection(w).u.vol.near = near;
  578.       MesaProjection(w).u.vol.far = far;
  579.     }
  580. }
  581.  
  582. void
  583. GLwSetOrthoProjection (Widget w,
  584.              GLdouble left, GLdouble right,
  585.              GLdouble bottom, GLdouble top,
  586.              GLdouble near, GLdouble far)
  587. {
  588.   if (is_workstation (w))
  589.     {
  590.       MesaProjection(w).type = ORTHO;
  591.       MesaProjection(w).u.vol.left = left;
  592.       MesaProjection(w).u.vol.right = right;
  593.       MesaProjection(w).u.vol.bottom = bottom;
  594.       MesaProjection(w).u.vol.top = top;
  595.       MesaProjection(w).u.vol.near = near;
  596.       MesaProjection(w).u.vol.far = far;
  597.     }
  598. }
  599.  
  600. GLuint
  601. GLwGetProjectionList (Widget w)
  602. {
  603.   if (is_workstation (w))
  604.     {
  605.       if (MesaProjection(w).type == PROJ_LIST)
  606.     return MesaProjection(w).list;
  607.     }
  608.   return 0;
  609. }
  610.  
  611. int
  612. GLwGetProjectionMatrix (Widget w, GLdouble *m)
  613. {
  614.   if (is_workstation (w))
  615.     {
  616.       if (MesaProjection(w).type == PROJ_MATRIX)
  617.     memcpy (m, MesaProjection(w).u.m, sizeof (MesaProjection(w).u.m));
  618.       return 1;
  619.     }
  620.   return 0;
  621. }
  622.  
  623. void
  624. GLwRedrawObjects (Widget w)
  625. {
  626.   if (is_workstation (w))
  627.     {
  628.       XMesaContext context = XMesaGetCurrentContext ();
  629.       XMesaMakeCurrent (MesaContext (w));
  630.       if (MesaProjection(w).type != NOPROJ)
  631.     {
  632.       glMatrixMode (GL_PROJECTION);
  633.       glPushMatrix ();
  634.       glLoadIdentity ();
  635.     }
  636.       switch (MesaProjection(w).type)
  637.     {
  638.     case PROJ_MATRIX:
  639.       glLoadMatrixd (MesaProjection(w).u.m);
  640.       break;
  641.     case PROJ_LIST:
  642.       if (!glIsList (MesaProjection(w).list))
  643.         XtAppWarning (XtWidgetToApplicationContext (w),
  644.               "Invalid projection list!");
  645.       else
  646.         glCallList (MesaProjection(w).list);
  647.       break;
  648.     case FRUSTUM:
  649.       mesa_frustum (MesaProjection(w).u.vol);
  650.       break;
  651.     case ORTHO:
  652.       mesa_ortho (MesaProjection(w).u.vol);
  653.       break;
  654.     case NOPROJ:
  655.       break;
  656.     }
  657.       glMatrixMode (GL_MODELVIEW);
  658.       glPushMatrix ();
  659.       {
  660.     GLuint *obj;
  661.     glLoadIdentity ();
  662.     switch (MesaView(w).type)
  663.       {
  664.       case PROJ_MATRIX:
  665.         glLoadMatrixd (MesaView(w).u.m);
  666.         break;
  667.       case PROJ_LIST:
  668.         if (!glIsList (MesaView(w).list))
  669.           XtAppWarning (XtWidgetToApplicationContext (w),
  670.                 "Invalid view list!");
  671.         else
  672.           glCallList (MesaView(w).list);
  673.         break;
  674.       case LOOK_AT:
  675.         mesa_look_at (MesaView(w).u.look_at);
  676.         break;
  677.       case POLAR:
  678.         mesa_polar (MesaView(w).u.polar);
  679.         break;
  680.       case NOVIEW:
  681.         break;
  682.       }
  683.     for (obj = MesaObjects (w); obj < MesaNextObject (w); obj++)
  684.       {
  685.         if (!glIsList (*obj))
  686.           XtAppWarning (XtWidgetToApplicationContext (w),
  687.                 "Invalid object list!");
  688.         else
  689.           {
  690.         glPushMatrix ();
  691.           glCallList (*obj);
  692.         glPopMatrix ();
  693.           }
  694.       }         
  695.       }
  696.       glPopMatrix ();
  697.       if (MesaProjection(w).type != NOVIEW)
  698.     {
  699.       glMatrixMode (GL_PROJECTION);
  700.       glPopMatrix ();
  701.       glMatrixMode (GL_MODELVIEW);
  702.     }
  703.       glFinish ();
  704.       XMesaSwapBuffers ();
  705.       XMesaMakeCurrent (context);
  706.     }
  707. }
  708.  
  709. /* obsolete aliases: */
  710.  
  711. void
  712. GLwPostView (Widget w, GLuint view)
  713. {
  714.   GLwPostViewList (w, view);
  715. }
  716.  
  717. GLuint
  718. GLwGetView (Widget w)
  719. {
  720.   return GLwGetViewList (w);
  721. }
  722.  
  723. void
  724. GLwPostProjection (Widget w, GLuint proj)
  725. {
  726.   GLwPostProjectionList (w, proj);
  727. }
  728.  
  729. GLuint
  730. GLwGetProjection (Widget w)
  731. {
  732.   return GLwGetProjectionList (w);
  733. }
  734.  
  735. /* The End. */
  736.  
  737.